package lt.vu.mif.os.resources;

import java.util.LinkedList;
import java.util.Queue;

import lt.vu.mif.os.VirtualMachine;

public class Resource {
	private boolean used;
	private int id; //which VM uses resource
	private Queue<VirtualMachine> queue  = new LinkedList();
	public Resource() {
	}
	
	public void setUsed(int id) {
		this.used = true;
		this.id = id;
	}
	
	private void setNotUsed() {
		this.used = false;
	}
	
	public boolean isUsed() {
		return used;
	}
	
	public int getId() {
		return id;
	}
	
	public VirtualMachine getFirstFromQueue() {
            if (!this.queue.isEmpty())
		return this.queue.remove();
            else
                return null;
	}
	
	public void addToQueue(VirtualMachine vm) {
		this.queue.add(vm);
	}
}
